<!DOCTYPE HTML>

<html>
<head>
<meta charset="utf-8" />
<title>文章投稿-{eyou:global name='web_name' /}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<link href="{eyou:global name='web_cmspath'/}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
{eyou:static file="users/skin/css/bootstrap.min.css"/}
    {eyou:static file="users/skin/css/basic.css"/}
    {eyou:static file="users/skin/css/eyoucms.css"/}
    {eyou:static file="users/skin/css/shop.css"/}
    {eyou:static  file="users/skin/css/tb_style.css"/}
    {eyou:include file="users/skin/css/diy_css.htm"/}

    {eyou:static file="/public/static/common/js/jquery.min.js"/}
    {eyou:static file="/public/plugins/layer-v3.1.0/layer.js"/}
    {eyou:static file="/public/static/common/js/tag_global.js"/}
    <script type="text/javascript" src="__STATIC__/admin/js/jquery-ui/jquery-ui.min.js"></script>
    </head>
    <body class="centre shop">

<!-- 头部 --> 
{eyou:include file="users/users_header.htm" /} 
<!-- 头部结束 --> 
<script type="text/javascript">
    window.UEDITOR_HOME_URL = "__ROOT_DIR__/public/plugins/Ueditor/";
</script> 
{eyou:static file="/public/plugins/Ueditor/ueditor.config.js"/}
{eyou:static file="/public/plugins/Ueditor/ueditor.all.min.js"/}
{eyou:static file="/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"/}
<div class="member-profile ey-member">
      <div class="container">
    <div class="member-profile-content">
          <div class="row"> 
        <!-- 侧边 --> 
        {eyou:include file="users/users_left.htm" /} 
        <!-- 侧边结束 --> 
        <!-- 中部 -->
        <div class="col-xs-12 col-sm-10 ey-member-safety" >
              <div class="panel m-b-0">
            <div class="panel-body ey-member-index ey-member-profile">
                  <div class="panel panel-default m-b-0 basic"> 
                <!-- 顶部导航栏 -->   
                <div class="panel-heading"> <strong>{$MenuTitle}</strong> </div>
                <!-- 顶部导航栏结束 -->  
             
               <div class="tb-body">
               	 <!-- 导航栏 --> 
                    {eyou:include file="users/release_bar.htm" /} 
                    <!-- END --> 
               </div>
                   
         
                <!-- 内容栏 -->
                <div class="panel-body" style="padding-top:0">
                      <form class="form-horizontal" id="post_form">
                          <input type="hidden" name="channel" value="0">
                    <div class="row">
                          <div class="col-xs-2">
                        <label for="title">文章标题<em style="color: red;">*</em></label>
                      </div>
                          <div class="col-xs-9">
                        <input type="text" name="title" value="" id="title" class="input-txt" maxlength="100">
                      </div>
                        </div>
                    <div class="row">
                          <div class="col-xs-2">
                        <label for="title">所属栏目<em style="color: red;">*</em></label>
                        </div>
                            <div class="col-xs-9">
                                {$arctype_html}
                            </div>
                        </div>
                    <div class="row">
                          <div class="col-xs-2">
                        <label for="title">TAG标签</label>
                      </div>
                          <div class="col-xs-9">
                        <input type="text" value="" name="tags" id="tags" class="input-txt">
                      </div>
                        </div>
                    {eq name='$is_litpic_users_release' value='1'}
                    <div class="row">
                          <div class="col-xs-2">
                        <label for="title">缩略图</label>
                      </div>
                          <div class="col-xs-9">
                        <div class="input-file-show div_litpic_local" {eyou:eq name='is_mobile' value='1'} onClick="GetUploadify_mobile(1,'','缩略图')" {eyou:else/} onClick="GetUploadify(1,'','allimg','litpic_call_back','','缩略图')" {/eyou:eq}> <img id='litpic_img'  src="__PUBLIC__/static/common/images/not_adv.jpg"/><span>上传缩略图</span>
                              <input type="hidden" name="litpic_inpiut" id='litpic_inpiut'>
                            </div>
                      </div>
                        </div>
                    {/eq}

                      <div class="row" style="display: none;" id="tupianji">
                          <div class="col-xs-2">
                              <label>图片集</label>
                          </div>
                          <div class="col-xs-9">
                              <div class="tab-pane pics" id="tab_imgupload">
                                  <a href="javascript:void(0);" onClick="GetUploadify(30,'','allimg','imgupload_call_back');" class="imgupload" title="拖动修改排序">
                                      <i class="fa fa-photo"></i>上传图片
                                  </a>
                                  <table class="table table-bordered">
                                      <tbody>
                                      <tr>
                                          <td class="sort-list">
                                              <div class="images_upload">
                                              </div>
                                          </td>
                                      </tr>
                                      </tbody>
                                  </table>
                              </div>
                              <!-- 上传图片显示的样板 start -->
                              <div class="images_upload_tpl none">
                                  <div class="images_upload">
                                      <div style="position: relative; height: 130px;">
                                          <input type="hidden" name="imgupload[]" value="" />
                                          <a href="javascript:void(0);" onClick="" class="upimg" title="拖动修改排序">
                                              <img src="__STATIC__/admin/images/add-button.jpg" width="120" height="120" />
                                          </a>
                                          <a href="javascript:void(0)" class="delect">&nbsp;&nbsp;</a>
                                      </div>
                                      <textarea rows="5" cols="60" name="imgintro[]" style="height:28px; width: 136px;" placeholder="图片注释" ></textarea>
                                  </div>
                              </div>
                              <!-- 上传图片显示的样板 end -->
                          </div>
                      </div>
                      <script type="text/javascript">

                          function img_call_back(fileurl_tmp)
                          {
                              $("#litpic_local").val(fileurl_tmp);
                              $("#img_a").attr('href', fileurl_tmp);
                              $("#img_i").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
                              $("input[name=is_litpic]").attr('checked', true); // 自动勾选属性[图片]
                          }

                          // 上传图集相册回调函数
                          function imgupload_call_back(paths){

                              var  last_div = $(".images_upload_tpl").html();
                              // var  last_div = $(".images_upload:last").prop("outerHTML");
                              for (var i=0;i<paths.length ;i++ )
                              {
                                  $(".images_upload:eq(0)").before(last_div);  // 插入一个 新图片
                                  $(".images_upload:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
                                  $(".images_upload:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
                                  $(".images_upload:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
                                  $(".images_upload:eq(0)").find('input').val(paths[i]); // 设置隐藏域 要提交的值
                              }
                          }
                          /*
                           * 上传之后删除组图input
                           * @access   public
                           * @val      string  删除的图片input
                           */
                          function ClearPicArr2(obj,path)
                          {
                              // 删除数据库记录
                              $.ajax({
                                  type:'POST',
                                  url:"{:url('user/UsersRelease/del_channelimgs', ['_ajax'=>1])}",
                                  data:{filename:path},
                                  success:function(){
                                      $(obj).parent().parent().remove(); // 删除完服务器的, 再删除 html上的图片
                                      $.ajax({
                                          type:'POST',
                                          url:"{:url('Uploadify/delupload', ['_ajax'=>1])}",
                                          data:{action:"del", filename:path},
                                          success:function(){}
                                      });
                                  }
                              });
                          }

                          /** 以下 图集相册的拖动排序相关 js*/

                          $( ".sort-list" ).sortable({
                              start: function( event, ui) {

                              }
                              ,stop: function( event, ui ) {
                              }
                          });
                          //因为他们要拖动，所以尽量设置他们的文字不能选择。 
                          $( ".sort-list" ).disableSelection();
                      </script>
                    <span id="FieldAddonextitem"></span>
                    <script type="text/javascript">
                        $(function() {
                            var typeidNew = {$typeid|default='0'};
                            if (0 == typeidNew) {
                                typeidNew = $('#typeid').find('option:selected').val();
                            }
                            GetAddonextitem(0, typeidNew, false);

                            $('#typeid').change(function() {
                                GetAddonextitem(1, $(this).val(), true);
                            });
                        });
                        
                        function GetAddonextitem(init, typeidNew, is_destroy) {
                            var channel = $("#typeid option:selected").attr('data-channel');
                            $("input[name='channel']").val(channel)
                            if (channel == 3){
                                $("#tupianji").show()
                            }else{
                                $("#tupianji").hide()
                            }

                            var loadingTxt = '正在加载';
                            if (1 == init) {
                                loadingTxt = '正在切换';
                            }
                            layer_loading(loadingTxt);

                            $.ajax({
                                url: "{:url('user/UsersRelease/get_addonextitem')}",
                                data: {typeid: typeidNew, _ajax:1},
                                type:'post',
                                success:function(res) {
                                    layer.closeAll();
                                    if (res.code == 0) {
                                        layer.alert(res.msg, {icon: 2, title:false});
                                    } else {
                                        $('#FieldAddonextitem').empty().html(res.data.html);
                                        if (1 == init) {
                                            $.each(res.data.htmltextField, function (index, value) {
                                                showEditor_1597892187('addonFieldExt_'+value);
                                            });
                                        }
                                    }
                                },
                                error: function(e){
                                    layer.closeAll();
                                    layer.alert(ey_unknown_error, {icon: 2, title:false});
                                }
                            });
                        }
                    </script>

                    <div class="row" style="border-bottom:none;">
                          <div class="col-xs-2"></div>
                          <div class="col-xs-9">
                        <input type="button" data-url="{:url('UsersRelease/article_add')}" onclick="AddArticle(this);" class="btn btn-primary" value="确认提交"/>
                      </div>
                        </div>
                    <!-- 表单验证 --> 
                    {$TokenValue}
                  </form>
                    </div>
                <!-- 内容栏结束 --> 
              </div>
                </div>
          </div>
            </div>
        <!-- 中部结束 --> 
      </div>
        </div>
  </div>
    </div>
<script type="text/javascript">
    // 去除 select中值相同的option(去重)，配合{$arctype_html}使用
    $(function(){
        var channel = $("#typeid option:selected").attr('data-channel');
        if (channel == 3){
            $("#tupianji").show()
        }
        $("#typeid option").each(function() {
            var val = $(this).val();
            if ($("#typeid option[value='" + val + "']").length > 1){
                $("#typeid option[value='" + val + "']:eq(0)").remove();
            }
        });
    });

    function MobileAddArticle(url = null) {
        $.getScript('__ROOT_DIR__/public/plugins/layer_mobile/layer.js?v={$version}', function(){
            // 提示信息，2秒自动关闭
            function MsgOpen(msgs){
                layer.open({
                    content: msgs,
                    skin: 'msg',
                    time: 2,
                });
            }
            // 提示动画
            function LoaDing(){
                var loading = layer.open({
                    type:2,
                    content: '正在处理',
                });
                return loading;
            }

            OnMobileAddArticle();
            function OnMobileAddArticle(){
                if (!$('#title').val()) {
                    MsgOpen('请填写文章标题！');
                    $('#title').focus();
                    return false;
                }

                if (0 == $('#typeid').val()) {
                    MsgOpen('请选择所属栏目！');
                    $('#typeid').focus();
                    return false;
                }
                LoaDing();
                $.ajax({
                    url: url,
                    data: $('#post_form').serialize(),
                    type:'post',
                    dataType:'json',
                    success:function(res){
                        layer.closeAll();
                        if (1 == res.code) {
                            MsgOpen(res.msg);
                            window.location.href = res.url;
                        } else {
                            MsgOpen(res.msg);
                            if (res.data) $('#'+res.data).focus(); 
                        }
                    }
                });
            }
        })
    }

    function AddArticle(obj){
        var url = $(obj).attr('data-url');
        if ('1' == '{$is_mobile}' && $('#litpic_inpiut').val()) {
            MobileAddArticle(url);return false;
        }

        if (!$('#title').val()) {
            layer.msg('请填写文章标题！', {time: 1500, icon: 2});
            $('#title').focus();
            return false;
        }
        if (0 == $('#typeid').val()) {
            layer.msg('请选择所属栏目！', {time: 1500, icon: 2});
            $('#typeid').focus();
            return false;
        }
        layer_loading('正在处理');
        $.ajax({
            url: url,
            data: $('#post_form').serialize(),
            type:'post',
            dataType:'json',
            success:function(res){
                layer.closeAll();
                if (1 == res.code) {
                    layer.msg(res.msg, {time: 1000},function(){
                        window.location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1500, icon: 2});
                    if (res.data) $('#'+res.data).focus(); 
                }
            },
            error : function() {
                layer.closeAll();
                layer.alert('网络失败，请刷新页面后重试', {icon: 5});
            }
        });
    }

    function litpic_call_back(fileurl_tmp)
    {
        $("#litpic_inpiut").val(fileurl_tmp);
        $("#litpic_img").attr('src', fileurl_tmp);
    }

</script> 
{eyou:include file="users/users_footer.htm" /} 

<!-- 底部结束 -->
